package com.arpa.wms.domain.enums;

import com.baomidou.mybatisplus.core.enums.IEnum;

import java.util.HashMap;
import java.util.Map;

/**
 * 仓储费类型
 *
 * @description:
 * @author: lxr
 * @create: 2020-11-18
 */
public enum StorageFeeTypeEnum implements IEnum<String> {
    /**
     * 仓储费类型
     */
    WHOLE("WHOLE", "包仓"),
    SCATTERED("SCATTERED", "零散");

    /**
     * 值
     */
    private final String value;

    /**
     * 描述
     */
    private final String desc;

    StorageFeeTypeEnum(final String value, final String desc) {
        this.value = value;
        this.desc = desc;
    }

    private static final Map<String, StorageFeeTypeEnum> map = new HashMap();

    static {
        StorageFeeTypeEnum[] values = values();
        int length = values.length;
        for (int i = 0; i < length; i++) {
            StorageFeeTypeEnum value1 = values[i];
            map.put(value1.getValue(), value1);
        }
    }


    public static StorageFeeTypeEnum getEnumByValue(String value) {
        return map.get(value);
    }

    /**
     * 根据描述，反向查找第一个符合的枚举对象
     *
     * @param desc
     * @return
     */
    public static StorageFeeTypeEnum getEnumByDesc(String desc) {
        for (StorageFeeTypeEnum item : map.values()) {
            if (item.getDesc().equals(desc)) {
                return item;
            }
        }
        return null;
    }

    @Override
    public String getValue() {
        return this.value;
    }

    @Override
    public String toString() {
        return this.desc;
    }

    public String getDesc() {
        return this.desc;
    }
}
